#pragma once

#include "BehaviorExecutionSpecification.h"

#include "Behavior.h"

namespace uml {

BehaviorExecutionSpecification::BehaviorExecutionSpecification(const QString& umlType)
    : ExecutionSpecification(umlType) {}

void BehaviorExecutionSpecification::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    ExecutionSpecification::fromJson(json, errorList);
    behavior_ = JsonSerializable::create<Behavior>(json.value("behavior"), errorList);

}

void BehaviorExecutionSpecification::toJson(QJsonObject& json) {
    ExecutionSpecification::toJson(json);
    if (behavior_) {
        QJsonObject behavior_json;
        behavior_->toJson(behavior_json);
        json.insert("behavior", behavior_json);
    }
}

/// <summary>
/// behavior getter
/// Behavior whose execution is occurring.
/// </summary>
shared_ptr<Behavior> BehaviorExecutionSpecification::behavior() const {
    return behavior_;
}

/// <summary>
/// behavior setter
/// Behavior whose execution is occurring.
/// </summary>
void BehaviorExecutionSpecification::setBehavior(shared_ptr<Behavior> value) {
    behavior_ = value;
}

} // namespace uml
